// console.log($('#remember').prop('checked'));
function loginSubmit() {
  const data = {};
  data.name = $("#name").val();
  data.password = $("#pwd").val();
  // console.log($('#remember')[0]);
  data.remember = $('#remember')[0].checked;
  //req to the router for log validation
  $.ajax({
    url: "/user/login",
    data: data,
    method: "POST",
    dataType: "JSON",
    success: function (res) {
      if (res.success) {
        location.replace("/views/pages/user1.html");
      } else if (res.role == 'admin') {
        location.replace(res.url);
      }
      else {
        console.log(res.msg);
        cl();
      }
    },
    error: function (err) {
      console.log("You got error man!!!?");
    },
  });
}
function showHidePwd() {
  const currentType = $("#pwd").attr("type");
  if (currentType == "password") {
    $("#pwd").attr("type", "text");
  } else {
    $("#pwd").attr("type", "password");
  }
}

function cl() {
  var pop = document.querySelector("#pop-up-block");
  pop.style.display = "block";
  var covering = document.querySelector(".main-pop");
  covering.style.display = "block";

}
function ml() {
  var pop = document.querySelector("#pop-up-block");
  pop.style.display = "none";
  var covering = document.querySelector(".main-pop");
  covering.style.display = "none"
}
